home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-04 / ms_sh21s.zip / SH210 / SRC / SHOWKEY.C < prev    next >
C/C++ Source or Header  |  1992-12-14  |  2KB  |  67 lines

  1. /* MS-DOS SHELL - Show Scan codes
  2.  *
  3.  * MS-DOS SHELL - Copyright (c) 1990,1,2 Data Logic Limited.
  4.  *
  5.  * This code is subject to the following copyright restrictions:
  6.  *
  7.  * 1.  Redistribution and use in source and binary forms are permitted
  8.  *     provided that the above copyright notice is duplicated in the
  9.  *     source form and the copyright notice in file sh6.c is displayed
  10.  *     on entry to the program.
  11.  *
  12.  * 2.  The sources (or parts thereof) or objects generated from the sources
  13.  *     (or parts of sources) cannot be sold under any circumstances.
  14.  *
  15.  *    $Header: /usr/users/istewart/src/shell/sh2.1/RCS/showkey.c,v 2.0 1992/07/16 14:35:08 istewart Exp istewart $
  16.  *
  17.  *    $Log: showkey.c,v $
  18.  * Revision 2.0  1992/07/16  14:35:08  istewart
  19.  * Release 2.0
  20.  *
  21.  *
  22.  */
  23.  
  24. #include <stdio.h>
  25. #include <unistd.h>
  26. #include <ctype.h>
  27. #include <dos.h>
  28.  
  29. void main (void)
  30. {
  31.     union REGS    Key;
  32.     union REGS    Shift;
  33.  
  34.     puts ("Control C to terminate");
  35.  
  36.     while (TRUE)
  37.     {
  38.     Key.x.ax = 0;
  39.     int86 (0x16, &Key, &Key);
  40.  
  41.     Shift.x.ax = 0x0200;
  42.     int86 (0x16, &Shift, &Shift);
  43.  
  44.     printf ("Scan = 0x%.4x ", Key.h.ah);
  45.     printf ("ASCII = 0x%.4x (%c) ", Key.h.al, isprint (Key.h.al) ?
  46.         Key.h.al : '.');
  47.     printf ("Shift = 0x%.4x ( ", Shift.h.al);
  48.  
  49.     if (Shift.h.al & 0x01)
  50.         printf ("Right Shift ");
  51.  
  52.     if (Shift.h.al & 0x02)
  53.         printf ("Left Shift ");
  54.  
  55.     if (Shift.h.al & 0x04)
  56.         printf ("Control ");
  57.  
  58.     if (Shift.h.al & 0x08)
  59.         printf ("Alt ");
  60.     
  61.     puts (")");
  62.  
  63.     if (Key.h.al == 0x03)
  64.         exit (0);
  65.     }
  66. }
  67.